<!--
 * @Author: zhangfeng
 * @Date: 2024-01-03 16:22:32
 * @LastEditTime: 2024-01-03 16:59:55
 * @LastEditors: zhangfeng
 * @Description: 
 * @FilePath: \manager\managersystem\src\components\utils\Icon.vue
 * © 2023 张峰，All rights reserved.
-->
<script lang="tsx">
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import { DefineComponent } from 'vue';
export default defineComponent({
	name: 'Icon',
	props: {
		icon: {
			type: String,
			default: '',
		},
		size: {
			type: Number,
			default: 16,
		},
	},
	setup(props: { size: number; icon: string }) {
		const renderIcon = (icon?: string) => {
			if (!icon) {
				return null;
			}
			const IconComp = (
				ElementPlusIconsVue as unknown as { [key: string]: DefineComponent }
			)[icon];
			return (
				<el-icon size={props.size}>
					<IconComp />
				</el-icon>
			);
		};
		return () => renderIcon(props.icon);
	},
});
</script>
